package cn.iocoder.yudao.module.ent.mq.producer.follow;

import cn.iocoder.yudao.module.ent.mq.message.follow.FollowSendMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 企业跟进记录 相关消息的 Producer
 */
@Slf4j
@Component
public class FollowProducer {

    @Resource
    private ApplicationContext applicationContext;

    /**
     * 发送 {@link cn.iocoder.yudao.module.ent.mq.message.follow.FollowSendMessage} 消息
     *
     * @param type          跟进类型
     * @param userId        负责人
     * @param entId         企业id
     * @param number        号码
     * @param callLogId     外呼记录id
     * @param callStatus    外呼状态
     * @param callRecordUrl 外呼录音url
     */
    public void sendReceiveMessage(String type, Long userId, String entId, String number, String content, Long callLogId, Boolean callStatus, String callRecordUrl) {
        FollowSendMessage message = new FollowSendMessage()
                .setUserId(userId)
                .setNumber(number)
                .setEntId(entId)
                .setType(type)
                .setContent(content)
                .setCallLogId(callLogId)
                .setCallStatus(callStatus)
                .setCallRecordUrl(callRecordUrl);

        applicationContext.publishEvent(message);
    }

}
